{% extends "base.html" %}
{% block header %}操作日志管理{% endblock %}
{% block content %}
<div class="card shadow-sm rounded p-4 mb-4">
    <h4 class="mb-3">操作日志</h4>
    <div class="table-responsive">
        <table class="table table-bordered align-middle">
            <thead class="table-light">
                <tr>
                    <th>用户</th>
                    <th>操作类型</th>
                    <th>详情</th>
                    <th>时间</th>
                </tr>
            </thead>
            <tbody>
                {% for log in page_obj %}
                <tr>
                    <td>{{ log.user }}</td>
                    <td>{{ log.get_action_display }}</td>
                    <td>{{ log.detail }}</td>
                    <td>{{ log.created_at }}</td>
                </tr>
                {% empty %}
                <tr><td colspan="4" class="text-center">暂无日志信息</td></tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    <nav>
        <ul class="pagination justify-content-center">
            {% if page_obj.number > 1 %}
            <li class="page-item"><a class="page-link" href="?page=1">首页</a></li>
            {% endif %}
            {% if page_obj.has_previous %}
            <li class="page-item"><a class="page-link" href="?page={{ page_obj.previous_page_number }}">上一页</a></li>
            {% endif %}
            <li class="page-item disabled"><span class="page-link">第 {{ page_obj.number }} 页 / 共 {{ page_obj.paginator.num_pages }} 页</span></li>
            {% if page_obj.has_next %}
            <li class="page-item"><a class="page-link" href="?page={{ page_obj.next_page_number }}">下一页</a></li>
            {% endif %}
            {% if page_obj.number < page_obj.paginator.num_pages %}
            <li class="page-item"><a class="page-link" href="?page={{ page_obj.paginator.num_pages }}">尾页</a></li>
            {% endif %}
        </ul>
    </nav>
</div>
{% endblock %}